#define _OLED_H_
#ifdef _OLED_H_

#include "gpio.h"
#include "stm32f1xx_hal.h"

#define OLED_FULL   0
#define OLED_HALF   1

/*OLED接受命令还是数据*/
#define cmd_mode        HAL_GPIO_WritePin(OLED_DC_GPIO_Port,OLED_DC_Pin,GPIO_PIN_RESET)
#define data_mode       HAL_GPIO_WritePin(OLED_DC_GPIO_Port,OLED_DC_Pin,GPIO_PIN_SET)
/*OLED片选信号*/
#define disable_oled    HAL_GPIO_WritePin(OLED_CS_GPIO_Port,OLED_CS_Pin,GPIO_PIN_SET)
#define enable_oled     HAL_GPIO_WritePin(OLED_CS_GPIO_Port,OLED_CS_Pin,GPIO_PIN_RESET)
/*字符芯片片选信号*/
#define enable_zk       HAL_GPIO_WritePin(OLED_CS_GPIO_Port,OLED_CS_Pin,GPIO_PIN_SET);    \
                        HAL_GPIO_WritePin(ZK_CS_GPIO_Port,ZK_CS_Pin,GPIO_PIN_RESET)
#define disable_zk      HAL_GPIO_WritePin(ZK_CS_GPIO_Port,ZK_CS_Pin,GPIO_PIN_SET)
/*时钟*/
#define clk_l           HAL_GPIO_WritePin(OLED_CLK_GPIO_Port,OLED_CLK_Pin,GPIO_PIN_RESET)
#define clk_h           HAL_GPIO_WritePin(OLED_CLK_GPIO_Port,OLED_CLK_Pin,GPIO_PIN_SET)
/*串型数据输出到OLED和字符芯片*/
#define input_l         HAL_GPIO_WritePin(OLED_MOSI_GPIO_Port,OLED_MOSI_Pin,GPIO_PIN_RESET)
#define input_h         HAL_GPIO_WritePin(OLED_MOSI_GPIO_Port,OLED_MOSI_Pin,GPIO_PIN_SET)
/*从字符读取信息的串型线*/
#define ROM_OUT         HAL_GPIO_ReadPin(ZK_MISO_GPIO_Port, ZK_MISO_Pin)

/*写指令到LCD模块*/
void transfer_command_lcd(int data1);
/*写数据到LCD模块*/
void transfer_data_lcd(int data1);
/*LCD模块初始化*/
void initial_lcd(void);
void lcd_address(unsigned char page, unsigned char column);
/*全屏清屏*/
void clear_screen(void);
/*显示128x64点阵图像*/
void display_128x64(const unsigned char *dp);
/*显示16x16点阵图像、汉字、生僻字或16x16点阵的其他图标*/
void display_graphic_16x16(unsigned int page, unsigned int column, const unsigned char *dp);
/*显示8x16点阵图像、ASCII, 或8x16点阵的自造字符、其他图标*/
void display_graphic_8x16(unsigned int page, unsigned char column, unsigned char *dp);
/*显示5*7点阵图像、ASCII, 或5x7点阵的自造字符、其他图标*/
void display_graphic_5x7(unsigned int page, unsigned char column, unsigned char *dp);
/****送指令到晶联讯字库IC***/
void send_command_to_ROM( unsigned char datu );
/****从晶联讯字库IC中取汉字或字符数据（1个字节）***/
static unsigned char get_data_from_ROM(void);
/*从相关地址（addrHigh：地址高字节,addrMid：地址中字节,addrLow：地址低字节）中连续读出DataLen个字节的数据到 pBuff的地址*/
void get_n_bytes_data_from_ROM(unsigned char addrHigh, unsigned char addrMid, unsigned char addrLow, unsigned char *pBuff, unsigned char DataLen );
/*显示GB2312字符串*/
void display_GB2312_string(unsigned char y, unsigned char x, unsigned char *text);
/*显示ASCII字符串*/
void display_string_5x7(unsigned char y, unsigned char x, unsigned char *text);
/*初始化OLED*/
void OLED_GBZK_GPIO_Config(void);
/*打印一个字节为三位十进制数*/
void print_byte( unsigned char y, unsigned char x, uint8_t n, uint8_t fullOrHalf );
void print_uint16( unsigned char y, unsigned char x, uint16_t n, uint8_t fullOrHalf );
void print_char( unsigned char y, unsigned char x, unsigned char n, uint8_t fullOrHalf );
void print_Hex1( unsigned char y, unsigned char x, unsigned char n, uint8_t fullOrHalf );
#endif
